#ifndef NET_CONTEXT_HPP
#define NET_CONTEXT_HPP


#include <list>
#include <vector>
#include <memory>
#include "beast.hpp"
#include "net.hpp"

namespace TWT {
namespace NetWork {

/// A pool of io_context objects.
class NetContext
{
public:
  /// Construct the io_context pool.
  explicit NetContext(std::size_t poolSize = 2);
  ~NetContext();

  /// Stop all io_context objects in the pool.
  void stop();
  net::io_context& getIoContext();

static NetContext& instance(){
    static NetContext instance_{2};
    return instance_;
}

private:
   std::vector<std::thread> threads_;
   net::io_context ioContext_;
   std::list<net::any_io_executor> work_;
};

} // NetWork
} // TWT

#endif // NET_CONTEXT_HPP
